import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';


class WeatherCard extends StatefulWidget {
  final String weather; // 例如：晴，多云，阴
  final double temperature; // 温度（整数）
  final IconData icon; // 天气图标

  const WeatherCard({super.key,
  required this.weather,
  required this.temperature,
  required this.icon});

  @override
  State<WeatherCard> createState() => _WeatherCardState();
}

class _WeatherCardState extends State<WeatherCard> {

  late double _height,_width;

  _WeatherCardState();

  @override
  Widget build(BuildContext context) {
    _height = MediaQuery.of(context).size.height;
    _width = MediaQuery.of(context).size.width;
    return SizedBox(
      width: _width * 0.40,
      height: _height * 0.08,
      child: Card(
        elevation: 4,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
        color: Colors.lightBlue.shade50,
        child: Padding(
          padding: EdgeInsets.zero,
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Lottie.asset("assets/sun.json",width: _width * 0.25,height: _height * 0.3),
              Padding(
                padding: const EdgeInsets.only(top: 8),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '${widget.temperature}°C',
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    Text(
                      widget.weather,
                      style: TextStyle(fontSize: 16, color: Colors.grey[700]),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

}

